
package jweslley.ContestVolumes.VolumeCII;

import java.math.BigInteger;
import java.util.Scanner;

import jweslley.Problem;
import jweslley.Problem.Status;

/**
 * 
 * http://icpcres.ecs.baylor.edu/onlinejudge/external/102/10220.html
 *
 * @author  Jonhnny Weslley
 * @version 1.00, 19/10/2008
 */
@Problem(Status.Accepted)
public class ILoveBigNumbers {

	public static void main(String[] args) {
		StringBuilder out = new StringBuilder();
		Scanner in = new Scanner(System.in);
		int n;		
		while (in.hasNext()) {
			n = in.nextInt();
			out
			.append(factorial(n))
			.append('\n');
		}
		System.out.print(out);
	}

	static Object factorial(int n) {
		BigInteger factorial = new BigInteger("1");
		while (n-- > 1) {
			factorial = factorial.multiply(new BigInteger(Integer.toString(n+1)));
		}
		String factorialAsStr = factorial.toString();
		long sum = 0;
		for (int j = 0; j < factorialAsStr.length(); j++) {
			sum += factorialAsStr.charAt(j) - '0';
		}
		return sum;
	}

}
